package com.woniuxy.carrental.controller;

import com.woniuxy.carrental.entity.PageBean;
import com.woniuxy.carrental.entity.ResponseResult;
import com.woniuxy.carrental.entity.Supply_part;
import com.woniuxy.carrental.service.SupplyPartService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xilei
 * @create 2021-10-05 下午 6:27
 */
@RestController
public class SupplyPartController {

    @Resource
    SupplyPartService supplyPartService;

    @GetMapping("/supplypartlist")
    public ResponseResult<PageBean<Supply_part>> getAllSupply_part(Integer pageIndex, Integer pageSize){
        List<Supply_part> list = supplyPartService.findSupply_partBy(pageIndex, pageSize);
        for(Supply_part a:list){
            System.out.println(a);
        }
        PageBean<Supply_part> pageBean = new PageBean<>();
        pageBean.setPageIndex(pageIndex);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecord(supplyPartService.findSupply_part().size());
        pageBean.setBeanList(list);
        return new ResponseResult<>(pageBean, 200, "OK");
    }

    @GetMapping("/supplypartlist1")
    public ResponseResult<PageBean<Supply_part>> getAllSupply_partBycarpart_id(Integer pageIndex, Integer pageSize,Integer carpart_id){

        List<Supply_part> list = supplyPartService.findSupply_partBycarpart_id(pageIndex, pageSize, carpart_id);
        for(Supply_part a:list){
            System.out.println(a);
        }
        PageBean<Supply_part> pageBean = new PageBean<>();
        pageBean.setPageIndex(pageIndex);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecord(supplyPartService.findSupply_part().size());
        pageBean.setBeanList(list);
        return new ResponseResult<>(pageBean, 200, "OK");
    }

}
